package com.ly.demo.lamdastream;

import java.util.Optional;
import java.util.stream.Stream;

/**
 * @author liuyang
 * @des
 * @Version 1.0
 * @Date: 28/06/2021 17:49
 */
public enum DaysOfWeekEnum {

    SUNDAY("off", 7),
    MONDAY("working", 1),
    TUESDAY("working", 2),
    WEDNESDAY("working", 3),
    THURSDAY("working", 4),
    FRIDAY("working", 5),
    SATURDAY("off", 6);

    private String typeOfDay;

    private int s;

    DaysOfWeekEnum(String typeOfDay, int s) {

        this.typeOfDay = typeOfDay;
        this.s = s;
    }

    public int getS() {
        return s;
    }

    public void setS(int s) {
        this.s = s;
    }

    public String getTypeOfDay() {
        return typeOfDay;
    }

    public void setTypeOfDay(String typeOfDay) {
        this.typeOfDay = typeOfDay;
    }

    public static Stream<DaysOfWeekEnum> stream() {
        return Stream.of(DaysOfWeekEnum.values());
    }

    public static DaysOfWeekEnum getDaysOfWeekEnum(int s) {
        Optional<DaysOfWeekEnum> m1 = EnumUtil.getEnumObject(DaysOfWeekEnum.class, e -> e.getS() == s);
        return m1.isPresent() ? m1.get() : null;
    }
}

